<template>
	<view style="width: 100%;min-height: 100vh;">
		<!-- 内容区 -->
		<view class="lists">
			<!-- 视频 -->
			<view style="display: flex;justify-content: space-between;box-sizing: border-box;padding: 0 20rpx;flex-wrap: wrap;">
				<view class="video-item" v-for="(item, i) in userinfo" :key="item.id" @tap.stop='toPlayVideo(item)'>
					<!-- <image class="video-item-img" :src="item." mode="aspectFill"></image> -->
					<template>
						<view class="item-img-box">
							<image class="video-item-img" :src="item.cover_url" mode="aspectFill"></image>
						</view>
						<view class="video-item-time">
							<text style="color: #FFFFFF;font-size: 20rpx;">{{item.video_time | filterVideoTime}}</text>
						</view>
						<view class="video-item-desc">
							<text
								style="color: #333333;font-weight: bold;padding-top: 10rpx;">{{item.title || ''}}</text>
							<text style="color: #666666;padding-top: 10rpx;">{{item.describe || ''}}</text>
							<!-- <text style="text-align: end;padding-top: 20rpx;color: #737373;"></text> -->
						</view>
						<!-- <view class="edit" @tap="editHandle(item)">编辑</view> -->
					</template>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userinfo: [],
				id: ''
			}
		},
		filters: {
			filterVideoTime(time) {
				if (!time) {
					return ''
				}
				const second = parseInt(time / 60)
				const minute = (time % 60 + '').slice(0, 2)
				return `${second < 10 ? '0' + second : second}:${minute < 10 ? '0' + minute : minute}`
			},

		},
		onLoad(o) {
			console.warn('列表=》', o.id)
			this.id = o.id
			this.getTeacherInfo()
		},
		methods: {
			// 获取老师信息
			async getTeacherInfo() {
				const res = await this.$http.request('/api/v1/author/show', {
					id: this.id
				}, 'GET')
				if (res.code == 200) {
					this.userinfo = res.data.shopList || []
					console.warn('列表=》', this.userinfo)
					// if (!Array.isArray(this.userinfo)) {
					// 	this.userinfo = []
					// }
				}
			},
			toPlayVideo(item) {
				uni.navigateTo({
					url: '/pages/teacher/video-play?videoInfo=' + JSON.stringify(item)
					// url: '/pages/teacher/video-common?videoInfo=' + JSON.stringify(item)
				})
			},
			editHandle(item) {
				uni.navigateTo({
					url: '/pages/user/user-uoload-video?query=' + JSON.stringify(item) + '&state=edit'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.lists {
		// border: 1rpx solid red;
		margin-top: 20rpx;

		.item-img-box {
			position: relative;

			.fengmian {
				@include flex-center(100%, 80rpx);
				position: absolute;
				bottom: 5rpx;
				left: 0;
				background-color: rgba($color: #000000, $alpha: .5);
				color: #FFFFFF;
			}
		}
	}

	.content {
		background-color: #EFEEF6;
	}

	.teacher-info {
		height: 560rpx;
		background-color: #f2f2f2;
		display: flex;
		flex-direction: column;
		justify-content: flex-end;
	}

	.detail {
		padding: 0 30rpx;
		border-radius: 40rpx 40rpx 0 0;
		background-color: #fff;
		height: 400rpx;
		position: relative;
		display: flex;
		flex-direction: column;
		justify-content: flex-end;
	}

	.video-list-items-img {
		@include flex-center(240rpx, 198rpx);
		position: relative;
		flex-direction: column;
		justify-content: center;
		border-radius: 20rpx;
		overflow: hidden;

		&>image {
			width: 240rpx;
			height: 240rpx;
			border-radius: 20rpx;
		}
	}

	.video-list-items-img-time {
		background-color: rgba(0, 0, 0, 0.4);
		width: 160rpx;
		height: 50rpx;
		text-align: center;
		display: flex;
		align-items: center;
		justify-content: center;
		position: absolute;
		top: 0;
		left: 0;
		border-radius: 20rpx 0 50rpx 0;
	}

	.video-list-items-desc {
		display: flex;
		flex-direction: column;
		justify-content: space-around;
		// margin-left: 40rpx;
		width: 366rpx;
		height: 210rpx;
	}

	.video-list-items-desc-price {
		display: flex;
		justify-content: flex-end;
	}

	/* 视频 */
	.video-item {
		position: relative;
		display: flex;
		flex-direction: column;
		justify-content: flex-start;
		background-color: #fff;
		border-radius: 20rpx;
		width: 345rpx;
		margin-bottom: 20rpx;
		box-sizing: border-box;
		.edit {
			margin-top: 20rpx;
			@include flex-center(188rpx, 60rpx);
			color: #fff;
			background: #5A77A3;
			border-radius: 80rpx;
			font-size: 28rpx;
			border-radius: 12rpx;
			margin: 0 auto;
		}
	}

	.video-item-time {
		background-color: rgba(0, 0, 0, 0.4);
		width: 140rpx;
		height: 50rpx;
		text-align: center;
		display: flex;
		align-items: center;
		justify-content: center;
		position: absolute;
		top: 0;
		left: 0;
		border-radius: 20rpx 0 50rpx 0;
	}

	.video-item-img {
		width: 345rpx;
		height: 320rpx;
		border-radius: 20rpx 20rpx 0 0;
	}

	.video-item-desc {
		padding: 20rpx 10rpx;
		display: flex;
		flex-direction: column;
	}


	.videos-right {
		padding-left: 0;
		flex-direction: column;
		justify-content: flex-start;
	}

	.videos-right .video-item-img {
		height: 260rpx;
	}

	/* 更多视频 */
	.morevideo {
		position: relative;
		height: 900rpx;
		border-radius: 20rpx 20rpx 0 0;
		background-color: white;
		padding: 20rpx;

		.price-box {
			@include flex-between(100%, 120rpx);
			position: fixed;
			bottom: 0;
			left: 0;
			background-color: #FFFFFF;
			box-shadow: 5rpx 0 10rpx rgba($color: #000000, $alpha: .3);
			padding: 0 20rpx 0 46rpx;
			z-index: 9999;

			.left-radio {
				.title {
					margin-left: 16rpx;
					font-size: 28rpx;
					color: #4D4D4D;
				}
			}

			.amount-box {
				display: flex;
				align-items: center;

				.amount {
					font-size: 28rpx;
					color: #4D4D4D;
					margin-right: 8rpx;
				}

				.price {
					font-size: 24rpx;
					color: #B91C27;
				}
			}

			.confirm-btn {
				@include flex-center(318rpx, 88rpx);
				background: #B91C27;
				border-radius: 44rpx;
				font-size: 36rpx;
				color: #FFFEFE;
			}

		}
	}

	.video-title-close {
		box-sizing: border-box;
		padding-top: 10rpx;
		margin-bottom: 40rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.video-list-name {
		display: flex;
		align-items: center;
	}

	.video-title {
		font-weight: bold;
		color: #4D4D4D;
		letter-spacing: 2rpx;
		box-sizing: border-box;
	}

	.video-title-icon {
		width: 12rpx;
		height: 40rpx;
		border-radius: 20rpx;
		margin-right: 20rpx;
		background-color: #B91C27;
	}
</style>
